<?php
die();
$conn = mysql_connect("sql.itmeeting.it.cloud.seeweb.it", "RMob", "RMob34XC088");
mysql_select_db("RMob");

date_default_timezone_set('Europe/Rome');

$lastupdate = query("select * from utils as u where u.key='UpdatedOn'");
$deltatime = (strtotime("now")-strtotime($lastupdate[0]['lastupdate']))/(60*60);
if($deltatime>=23 || $argv[1]=="go"){
/*   if(date("N")==1) */
/*     file_get_contents_curl("http://www.sapienzaapps.it/RMob/iPhone-Server/Services/CacheService.php");		 */
  file_get_contents_curl("http://www.sapienzaapps.it/RMob/iPhone-Server/Services/Cache.php");	
  file_get_contents_curl("http://www.sapienzaapps.it/RMob/iPhone-Server/Services/AddNewBusStops.php");	
  file_get_contents_curl("http://www.sapienzaapps.it/RMob/iPhone-Server/Services/Stops_Unavailable.php");	
  query("replace utils set utils.key='UpdatedOn', utils.value='1'");
}

function query($query)
{ 
  global $conn;
  $a = array();
  $ris = mysql_query($query,$conn);
  $mysqlerrno = mysql_errno($conn); 
  if ($mysqlerrno != 0)
    { 
      return false;
    }
  else if ($ris === true)
    return true;
  else
    while ($row = mysql_fetch_array($ris,MYSQL_ASSOC))
      $a[] = $row;
  return $a;  
}

function file_get_contents_curl($url) {
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_HEADER, false);
  curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
  curl_setopt($ch, CURLOPT_URL, $url);
  $data = curl_exec($ch);
  curl_close($ch);
  
  return $data;
}


?>